Skip to content

feat: add OpenRouter quantization filter to exclude low-bit providers (rebased)#11717

Open
roomote[bot] wants to merge 3 commits intomainfrom
feature/openrouter-quantization-filter-v2
Open

feat: add OpenRouter quantization filter to exclude low-bit providers (rebased)#11717
roomote[bot] wants to merge 3 commits intomainfrom
feature/openrouter-quantization-filter-v2

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 24, 2026

Related GitHub Issue

Closes: #11325

Description

This PR attempts to address Issue #11325 by re-implementing the feature from PR #11366 on a clean branch from main, since that PR had unresolvable merge conflicts due to significant codebase changes since it was created.

Changes:

  1. Schema (packages/types/src/provider-settings.ts): Added openRouterExcludeLowQuantization: z.boolean().optional() to the openRouterSchema.

  2. Handler (src/api/providers/openrouter.ts): Added a buildProviderOptions() private method that centralizes provider option construction for both createMessage() and completePrompt(). When the setting is enabled, provider.quantizations is set to ["fp16", "bf16", "fp8", "int8"], restricting to higher-precision providers. This also combines with the existing specific provider routing when both are set.

  3. UI (webview-ui/src/components/settings/providers/OpenRouter.tsx): Added a checkbox labeled "Exclude low-bit quantization (FP4/FP6/Int4)" with a description explaining the CJK encoding fix.

  4. i18n: Added English translations and fallback values for all 17 non-English locales.

Test Procedure

  • Added 6 new tests in src/api/providers/__tests__/openrouter.spec.ts covering buildProviderOptions():
    • Returns undefined when no specific provider and no quantization filter
    • Returns provider routing when specific provider is set
    • Returns quantizations when excludeLowQuantization is enabled
    • Combines specific provider and quantization filter correctly
    • Returns undefined when specific provider is the default "[default]"
    • Returns undefined when excludeLowQuantization is false
  • All 30 tests pass: cd src && npx vitest run api/providers/__tests__/openrouter.spec.ts
  • Translation check passes: node scripts/find-missing-translations.js

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The setting defaults to off, preserving existing behavior. When enabled, it uses the OpenRouter documented provider.quantizations API field to restrict routing to higher-precision providers only. Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Adds an opt-in checkbox to filter out low-bit quantization providers
(FP4/FP6/Int4) when using OpenRouter, preventing broken CJK encoding.

- Add openRouterExcludeLowQuantization to provider settings schema
- Add buildProviderOptions() method to centralize provider options
- Add UI checkbox in OpenRouter settings
- Add i18n translations for all 18 locales
- Add 6 tests for buildProviderOptions behavior

Closes #11325
@jongleeat
Copy link

@roomote
You used english for check-translation ci. Could you fix proper language for each i18n/locales translation ?

@roomote
Copy link
Contributor Author

roomote bot commented Feb 24, 2026

Fixaroo Clock   See task

Translated the excludeLowQuantization label and description into proper native language for all 17 non-English locales. Translation validation script passes cleanly.

View commit | Revert commit

@jongleeat
Copy link

@roomote
This PR is now on "Review required". Please assign a reviewer to merge this pull request.

@roomote
Copy link
Contributor Author

roomote bot commented Feb 24, 2026

Fixaroo Clock   See task

Marked this PR as ready for review. All 30 tests pass and translations are complete.

@roomote roomote bot marked this pull request as ready for review February 24, 2026 03:09
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Feb 24, 2026
@jongleeat
Copy link

@roomote
What is my next step ? What should I ask for?

@roomote
Copy link
Contributor Author

roomote bot commented Feb 26, 2026

Proofessor Clock   See task

Your PR is in great shape! Here's where things stand and what to do next:

Current status:

  • All CI checks pass (compile, lint, knip, unit tests on Ubuntu + Windows, check-translations, CodeQL)
  • The PR is marked ready for review and is mergeable
  • Review requests are already out to maintainers (mrubens, cte, jr, hannesrudolph, daniel-lxs)

Minor improvement pushed: I cached the buildProviderOptions() call to avoid invoking it twice per request (once for the truthiness check and once for the value). All tests still pass.

Your next step: Wait for a maintainer to review. If no one responds within a few days, you could politely ping one of the requested reviewers in a comment asking if they've had a chance to look at it. No further code changes should be needed on your end unless a reviewer requests them.

View commit | Revert commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] UI Option to Filter OpenRouter Quantization (FP4/Int4) to Fix CJK Encoding Issues

2 participants